﻿namespace Authentication.Data.DBConfig
{
    using Authentication.Configuration;
    using Authentication.Model.Model;
    using Common.Data.Extensions;
    using System.Data.Entity.ModelConfiguration;

    public class AccountInfoConfiguration : DBConfig<AccountInfo>
    {
        public AccountInfoConfiguration()
            : base(SystemConfiguration.Schema, SystemConfiguration.NamingType, SystemConfiguration.TABLE_PREFIX)
        {
            HasKey(k => new { k.ApplicationKey, k.UserName });
            Property(c => c.ApplicationKey).HasMaxLength(36).IsRequired();
            Property(c => c.UserName).HasMaxLength(128).IsRequired();

            //relationship  
            HasRequired(ad => ad.Account).WithOptional(s => s.AccountInfo);
        }
    }
}